package admin

import database "hft/Database"

type FileGroup struct {
	database.Base
	PID       int                      `json:"pid" gorm:"foreignKey:PID;references:ID;OnDelete:CASCADE,OnUpdate:NO ACTION"`
	Name      string                   `json:"name" gorm:"uniqueIndex:name_account_id"`
	AccountId int                      `json:"-" gorm:"uniqueIndex:name_account_id"`
	Link      string                   `json:"-" gorm:"index"`
	Files     []*FileUploadAndDownload `json:"files,omitempty" gorm:"foreignKey:GroupId;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	Directory []*FileGroup             `json:"children,omitempty" gorm:"foreignKey:PID;references:ID;OnDelete:CASCADE,OnUpdate:NO ACTION"`
}

func (FileGroup) TableName() string {
	return database.TableNameFormat("file_group")
}
